﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MeshSharp.Core.Models
{
    public class Vector3
    {
        public Vector3(float x, float y, float z)
        {
            X = x;
            Y = y;
            Z = z;
        }
        public static bool operator !=(Vector3 self, Vector3 other)
        {
            return (self.X != other.X || self.Y != other.Y || self.Z != other.Z);
        }
        public static bool operator ==(Vector3 self, Vector3 other)
        {
            return (self.X == other.X && self.Y == other.Y && self.Z == other.Z);
        }
        public static Vector3 operator +(Vector3 self, Vector3 other)
        {
            return new Vector3(self.X + other.X, self.Y + other.Y, self.Z + other.Z);
        }
        public static Vector3 operator -(Vector3 self, Vector3 other)
        {
            return new Vector3(self.X - other.X, self.Y - other.Y, self.Z - other.Z);
        }
        public static Vector3 operator /(Vector3 self, float scalar)
        {
            return new Vector3(self.X / scalar, self.Y / scalar, self.Z / scalar);
        }
        public static double Distance(Vector3 v1, Vector3 v2)
        {
            return Math.Sqrt(Math.Pow((v2.X - v1.X), 2) + Math.Pow((v2.Y - v1.Y), 2));
        }
        public float X { get; set; }
        public float Y { get; set; }
        public float Z { get; set; }

        public Vector3()
        {
        }

        public override bool Equals(object obj)
        {
            var v = obj as Vector3;
            if (obj != null)
            {
                return (this == v);
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            string combined = string.Format("{0}-{1}-{2}", this.X, this.Y, this.Z);
            return (combined.GetHashCode());
        }
    }
}
